package com.example.task1.ui.AllService.garbage;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.application.MyApplication;
import com.example.task1.bean.GarbageDetailsListBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class GarbageDetailsListAdapter extends BaseAdapter<GarbageDetailsListBean.RowsDTO> {

    private Context context;
    private List<GarbageDetailsListBean.RowsDTO> mData = new ArrayList<>();
    private TextView tvName;
    private ImageView image;

    public GarbageDetailsListAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected void setData(List<GarbageDetailsListBean.RowsDTO> rows) {
        int size = mData.size();
        mData.addAll(rows);
        notifyItemInserted(size);
    }

    @Override
    protected int getLayout() {
        return R.layout.garbagedetailstlist;
    }

    @Override
    protected Context getContext() {
        return null;
    }

    @Override
    protected List<GarbageDetailsListBean.RowsDTO> getData() {
        return mData;
    }

    @Override
    protected void onBind(myHolder holder, GarbageDetailsListBean.RowsDTO date) {
        tvName.setText(date.getName());
        MyApplication.glide(image, date.getImgUrl());
    }

    @Override
    protected void holder(View view) {
        initView(view);
    }

    private void initView(View view) {
        tvName = view.findViewById(R.id.tv_name);
        image = view.findViewById(R.id.image);
    }
}
